//
//  ChargeMoneyCCell.m
//  ImGuider
//
//  Created by 李陆涛 on 2018/1/3.
//  Copyright © 2018年 imguider. All rights reserved.
//

#import "ChargeMoneyCCell.h"

@interface ChargeMoneyCCell ()
@property (weak, nonatomic) IBOutlet UILabel *moenyLabel;
@property (weak, nonatomic) IBOutlet UILabel *coinLabel;
@property (weak, nonatomic) IBOutlet UIImageView *youhuiBGImageView;
@property (weak, nonatomic) IBOutlet UILabel *youhuiLabel;

@property (weak, nonatomic) IBOutlet UIImageView *selectBG;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *coinLabelHeight;
    
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *centerY;
    
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *priceLabeHeight;
    
@end

@implementation ChargeMoneyCCell

- (void)awakeFromNib {
    
    [super awakeFromNib];
    self.selectBG.hidden = YES;
    self.youhuiBGImageView.hidden = YES;
    self.layer.borderWidth = 2.0f;
    self.layer.borderColor = kBGColor.CGColor;
    self.moenyLabel.textColor = kSubitleColor;
    self.priceLabel.textColor = kSubitleColor;
    self.priceLabel.font = Font(12);
    self.priceLabel.textAlignment = NSTextAlignmentCenter;
    self.coinLabel.textColor = kThemeRedColor;
}

- (void)setIsSelect:(BOOL)isSelect {
    
    _isSelect = isSelect;
    
    self.layer.borderColor = isSelect ? kThemeColor.CGColor : kBGColor.CGColor;
}

- (void)setCoinModel:(ChargeCoinModel *)coinModel  {
    
    _coinModel = coinModel;
    NSString *str1 = [NSString stringWithFormat:@"%d",(int)coinModel.coin];
    NSString *str2 = MYLocalizedString(@"PUBLIC_COIN_NAME", nil);
    
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ %@",str1,str2]];
    
    [attrStr addAttribute:NSFontAttributeName value:Font(16) range:str1.rangeOfAll];
    [attrStr addAttribute:NSForegroundColorAttributeName value:kSubitleColor range:str1.rangeOfAll];
    [attrStr addAttribute:NSFontAttributeName value:Font(12) range:NSMakeRange(str1.length, str2.length+1)];
    [attrStr addAttribute:NSForegroundColorAttributeName value:kContentColor range:NSMakeRange(str1.length, str2.length +1)];
    self.moenyLabel.attributedText = attrStr;
    self.priceLabel.text = coinModel.name;
    self.priceLabel.backgroundColor = kBGColor;
    if (coinModel.song > 0) {
        self.centerY.constant = -15;
        self.coinLabel.text = [NSString stringWithFormat:@"%@%d%@",MYLocalizedString(@"PUBLIC_COIN_SEND", nil),(int)coinModel.song,MYLocalizedString(@"PUBLIC_COIN_NAME", nil)];
        self.coinLabelHeight.constant = self.size.height/7 *2;
//        if (self.isSelect) {
//            self.youhuiBGImageView.hidden = YES;
//            self.youhuiLabel.hidden = YES;
//
//            self.moenyLabel.textColor = [UIColor whiteColor];
//            self.coinLabel.textColor = [UIColor whiteColor];
//        } else {
//            self.youhuiBGImageView.hidden = NO;
//            self.youhuiLabel.hidden = NO;
//
//            self.moenyLabel.textColor = kSubitleColor;
//            self.coinLabel.textColor = kThemeRedColor;
//        }
        
    } else {
        
//        self.youhuiBGImageView.hidden = YES;
//        self.youhuiLabel.hidden = YES;
        self.centerY.constant = -5;
        self.coinLabel.text = @"";
        self.coinLabelHeight.constant = 0;
//        if (self.isSelect) {
//
//            self.moenyLabel.textColor = [UIColor whiteColor];
//            self.coinLabel.textColor = [UIColor whiteColor];
//        } else {
//            self.moenyLabel.textColor = kSubitleColor;
//            self.coinLabel.textColor = kContentColor;
//        }
    }
}

@end
